package cn.gz.demo.ui;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;

import androidx.databinding.DataBindingUtil;

import cn.gz.demo.R;
import cn.gz.demo.databinding.LineBinding;
import cn.gz.demo.ui.base.BaseActivity;
import cn.gz.demo.utils.DisplayUtil;

/**
 * @author Liuyz
 * @date 2020/12/1 18:04
 */
public class LineActivity extends BaseActivity {
    private LineBinding binding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_line);

        binding.contentLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                binding.contentLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                binding.bottomLine.setVisibility(View.VISIBLE);
                ViewGroup.LayoutParams lp = binding.bottomLine.getLayoutParams();
                lp.height = DisplayUtil.dip2px(context, 10) + binding.contentLayout.getHeight();
                lp.width = DisplayUtil.dip2px(context, 2);
            }
        });
    }
}
